<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = "http://localhost:8080/wechatEnterprise/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
<title>意向客户录入</title>
	<link rel="shortcut icon" href="../favicon.ico">
	<link rel="stylesheet" href="<%=basePath%>css/bxweixin.css"/>
	<link rel="stylesheet" href="<%=basePath%>css/jquery.mobile.icons.min.css" />
	<link rel="stylesheet" href="<%=basePath%>css/jquery.mobile.structure-1.4.5.min.css"/>
	<link rel="stylesheet" href="<%=basePath%>css/mobiscroll.custom-2.6.2.min.css" />
	<script src="<%=basePath%>js/common_vladate.js"></script> 
	<script src="<%=basePath%>js/jquery-1.11.0.min.js"></script>
	<script src="<%=basePath%>js/jquery.mobile-1.4.5.min.js"></script>
	<script src="<%=basePath%>js/mobiscroll.custom-2.6.2.min.js"></script>
	<script type="text/javascript" src="<%=basePath%>js/common.js?1=1"></script>
	<!-- 主要样式 -->
    <link rel="stylesheet" type="text/css" href="<%=basePath%>css/base2013.css" >
    <!--弹出框-->
     <script src="<%=basePath%>js/jquery.lt_alert.js"></script>
    <script type="text/javascript" src="<%=basePath%>js/common.js?1=1"></script>
	<link rel="stylesheet" type="text/css" href="<%=basePath%>css/enterCustomerInfo.css" >
<script type="text/javascript">
 
/**
* 实时动态强制更改用户录入
* 金额限制
**/
function amount(th){
    var regStrs = [
        ['^0(\\d+)$', '$1'], //禁止录入整数部分两位以上，但首位为0
        ['[^\\d\\.]+$', ''], //禁止录入任何非数字和点
        ['\\.(\\d?)\\.+', '.$1'], //禁止录入两个以上的点
        ['^(\\d+\\.\\d{2}).+', '$1'] //禁止录入小数点后两位以上
    ];
    for(i=0; i<regStrs.length; i++){
        var reg = new RegExp(regStrs[i][0]);
        th.value = th.value.replace(reg, regStrs[i][1]);
    }
}
 
/**
* 录入完成后，输入模式失去焦点后对录入进行判断并强制更改，并对小数点进行0补全
* arg1 inputObject
* 这个函数写得很傻，是我很早以前写的了，没有进行优化，但功能十分齐全，你尝试着使用
* 其实有一种可以更快速的JavaScript内置函数可以提取杂乱数据中的数字：
* parseFloat('10');
**/
function overFormat(th){
    var v = th.value;
    if(v === ''){
        v = '0.00';
    }else if(v === '0'){
        v = '0.00';
    }else if(v === '0.'){
        v = '0.00';
    }else if(/^0+\d+\.?\d*.*$/.test(v)){
        v = v.replace(/^0+(\d+\.?\d*).*$/, '$1');
        v = inp.getRightPriceFormat(v).val;
    }else if(/^0\.\d$/.test(v)){
        v = v + '0';
    }else if(!/^\d+\.\d{2}$/.test(v)){
        if(/^\d+\.\d{2}.+/.test(v)){
            v = v.replace(/^(\d+\.\d{2}).*$/, '$1');
        }else if(/^\d+$/.test(v)){
            v = v + '.00';
        }else if(/^\d+\.$/.test(v)){
            v = v + '00';
        }else if(/^\d+\.\d$/.test(v)){
            v = v + '0';
        }else if(/^[^\d]+\d+\.?\d*$/.test(v)){
            v = v.replace(/^[^\d]+(\d+\.?\d*)$/, '$1');
        }else if(/\d+/.test(v)){
            v = v.replace(/^[^\d]*(\d+\.?\d*).*$/, '$1');
            ty = false;
        }else if(/^0+\d+\.?\d*$/.test(v)){
            v = v.replace(/^0+(\d+\.?\d*)$/, '$1');
            ty = false;
        }else{
            v = '0.00';
        }
    }
    th.value = v; 
}
</script>
</head>
<script >
var rateArr=null;
var minAge=3;
var maxAge=80;
$(document).ready(function() {
    $('input:jqmData(role="datebox")').mobiscroll().date();
    minAge=3;
    maxAge=5;
    loadDateP(minAge,maxAge);
    var now = new Date();               
    //或全今天的日期-显示为日期和时间
      Date.prototype.Format = function (fmt) { //author: meizz 
    var o = {
        "M+": this.getMonth() + 1, //月份 
        "d+": this.getDate(), //日 
        "h+": this.getHours()+1, //小时 
        "m+": this.getMinutes(), //分 
        "s+": this.getSeconds(), //秒 
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
        "S": this.getMilliseconds() //毫秒 
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}
var time = new Date().Format("yyyy-MM-dd hh:mm");
         for(var i=1;i<=5;i++){
	    	 document.getElementById("startDate"+i).value=time;
	    }
         console.log( $("#startDate1").val());
 
});
/**
 * 重置日期控件日期范围
 */
function loadDateP(_minAge,_maxAge){
	var opts = {
			preset: 'datetime', //日期 date、datetime、time
	        theme: 'ios', //皮肤样式
	        display: 'bottom', //显示方式 modal
	        mode: 'scroller', //日期选择模式
	        dateFormat: 'yy-mm-dd', // 日期格式
	        timeFormat: 'HH:ii',
	        setText: '确定', //确认按钮名称
	        cancelText: '取消',//取消按钮名籍我
	        dateOrder: 'yymmdd', //面板中日期排列格式
	        dayText: '日', monthText: '月', yearText: '年', hourText: '时',minuteText: '分',//面板中年月日文字
	        startYear:new Date().getFullYear()-(_maxAge*1),//开始年份
	       endYear:new Date().getFullYear()+(_minAge*1),//结束年份
	        onSelect:function(obj)
 			{ 
	        	obj = obj.replace(/\-/g, "/");
	        } 
	    };
	    for(var i=1;i<=5;i++){
	    	 $('#startDate'+i).mobiscroll(opts);
	    }
	  
}

function  alertnew(content1){

	console.log(content1);
	$.lt_alert({
		type: "prompts",
		right_close:true,
		timeout:300000,
		content: content1
	});

 } 

function  jiaoyan(){

			if($("#companyName").val() == null || $("#companyName").val() == ""){
				alertnew('公司全称不可以为空');
				$(".ui-mask").height($(window).height());
				return false ;
			}
	    	if($("#companyShort").val() == null || $("#companyShort").val() == ""){
				alertnew('公司简称不可以为空');
				$(".ui-mask").height($(window).height());
				return false ;
	    	}
	    	if($("#companyAddress").val() == null || $("#companyAddress").val() == ""){
				alertnew('地址不可以为空');
				$(".ui-mask").height($(window).height());
				return false ;
	    	}
	    	if($("#companyMobile").val() == null || $("#companyMobile").val() == ""){
				alertnew('联系电话不可以为空');
				$(".ui-mask").height($(window).height());
				return false ;
	    	}
	    	if($("#companyPeople").val() == null || $("#companyPeople").val() == ""){
				alertnew('联系人不可以为空');
				$(".ui-mask").height($(window).height());
				return false ;
	    	}
	    	if($("#companyNumPeople").val() == null || $("#companyNumPeople").val() == ""){
				alertnew('员工人数不可以为空');
				$(".ui-mask").height($(window).height());
				return false ;
	    	}
	    	if($("#quoteOnePrice").val() == null || $("#quoteOnePrice").val() == ""){
				alertnew('单价不可以为空');
				$(".ui-mask").height($(window).height());
				return false ;
	    	}
	    	if($("#quoteTotalSum").val() == null || $("#quoteTotalSum").val() == ""){
				alertnew('总金额不可以为空');
				$(".ui-mask").height($(window).height());
				return false ;
	    	}
	    	if($("#companyPhysicalM").val() == null || $("#companyPhysicalM").val() == ""){
				alertnew('体检月份不可以为空');
				$(".ui-mask").height($(window).height());
				return false ;
	    	}
	    	if($("#mechanismAgoName").val() == null || $("#mechanismAgoName").val() == ""){
				alertnew('往年服务机构不可以为空');
				$(".ui-mask").height($(window).height());
				return false ;
	    	}
	    	if($("#turnoverProbability").val() == null || $("#turnoverProbability").val() == ""){
				alertnew('成交机率不可以为空');
				$(".ui-mask").height($(window).height());
				return false ;
	    	}
			
			return true;
}
/**
 * 全部提交时候的判断和提示
 * 
 */
 var eloveCheck = new EloveCheck();
 
function checkFormArea(){	
	    	//联系电话校验
		    var toubaorenDh = eloveCheck.trim($("#companyMobile").val());
		    if(eloveCheck.isBlank(toubaorenDh)){
		    	alertnew("客户联系电话为空");
		        return false;
		    }
		    if(!eloveCheck.isPhone(toubaorenDh) && !eloveCheck.checkMobile(toubaorenDh)){
		    	alertnew("请输入正确的联系电话");
		        return false;
		    }
			return true;
}

//提交表单
function forsubmit(){
/*
	if(!jiaoyan()){
		console.log("进入判断");
		return;
	}	
    if(!checkFormArea()){
		console.log("进入校验");
		return;
	}*/
	 //返回错误信息
   //	showLoading();
	$.ajax({
		url:'<%=basePath%>customer/ajaxCompanyInfo',
		type:'post',
		data:$('#companyInfo').serialize(),
		dataType:'json',
		success:function(data){
			//hideLoading();
			//var json=data;
			//if(json.state!="200"){
        	//	alert(data.msg);
        	//	return;
        //	}
			alert("success");
		},
		error:function(data){
	    	hideLoading();
	    	console.log(data);
            alert("抱歉，请求失败，请稍候再试！");
		}
		});
   	
}


//显示----隐藏 基本信息
function showtk(layerIndex){
	if(layerIndex==1){
		if($("#jibenxinxi").css("display")=="block"){
			$("#zhedie"+layerIndex).html("+");
			$("#jibenxinxi").hide();
		}else{
			$("#jibenxinxi").show();
			$("#zhedie"+layerIndex).html("一");
		}
	}else{
		if($("#genjinjilu").css("display")=="block"){
			$("#zhedie"+layerIndex).html("+");
			$("#genjinjilu").hide();
		}else{
			$("#genjinjilu").show();
			$("#zhedie"+layerIndex).html("一");
		}
	}
}

//追加 访问记录
function addRecord(){
	for(var i=1;i<=5;){
		var  num=i;
	    if($("#genjin_info"+num).css("display")=="block"){
	    	i++;
		}
	    if($("#genjin_info"+num).css("display")=="none"){
	    	$("#genjin_info"+num).show();
	    	return true;
		}
	}
}
</script>
<body class="ui-mobile-viewport ui-overlay-a body">
<form id="companyInfo" action="<%=basePath %>customer/ajaxCompanyInfo" method="post">

<div role="main" class="ui-content">

	<div class="ui-body ui-body-b ui-corner-all none-border" data-theme="b">
	    <span class="con-title bg-orange">填写客户基本信息<span class="right-white color-orange" id="zhedie1" onclick="showtk('1')">一</span></span>
	    <div style="height:30px;"></div>
	    <div id="jibenxinxi" style="display:block;">
									<div class="text">
										<div class="name" for="companyName">公司全称</div>
											<input type="text" id="companyName" name="companyName" placeholder="必填"  value="">	
									</div>
									<div class="text">
										<div class="name" for="companyShort" >公司简称</div>
							    			<input type="text"  id="companyShort" placeholder="必填"  >
							   		 </div>
							   		 <div class="text">
										<div class="name" for="companyAddress">地址</div>
											<input type="text" id="companyAddress" placeholder="必填"  value="">	
									</div>
									<div class="text">
										<div class="name" for="companyMobile" >联系电话</div>
							    			<input type="text"  id="companyMobile" placeholder="必填"  >
							   		 </div>
							   		 <div class="text">
										<div class="name" for="companyPeople">联系人</div>
											<input type="text" id="companyPeople" placeholder="必填"  value="">	
									</div>
									<div class="text">
										<div class="name" for="companyJob" >职务</div>
											<select   id="companyJob"  	 data-native-menu="true" data-theme="a" >
															<option value="01" >总经理</option>
															<option value="02" >总监</option>
															<option value="03" >部门经理</option>
															<option value="04">销售人员</option>
											</select>
							   		 </div>
							   		 <div class="text">
										<div class="name" for="companyNumPeople">员工人数</div>
											<input type="text" id="companyNumPeople" placeholder="必填"  onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"  
                                    onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'0')}else{this.value=this.value.replace(/\D/g,'')}"/>	
									</div>
									<div class="text">
										<div class="name" for="quoteOnePrice" >单价</div>
							    			<input type="text"  id="quoteOnePrice" placeholder="必填"  onKeyUp="amount(this)" onBlur="overFormat(this)" >
							   		 </div>
							   		 <div class="text">
										<div class="name" for="quoteTotalSum">总金额</div>
											<input type="text" id="quoteTotalSum" placeholder="必填"  onKeyUp="amount(this)" onBlur="overFormat(this)">	
									</div>
									<div class="text">
										<div class="name" for="companyPhysicalM" >体检月份</div>
							    			<select   id="companyPhysicalM"  	 data-native-menu="true" data-theme="a" >
															<option value="01" >1月</option>
															<option value="02" >2月</option>
															<option value="03" >3月</option>
															<option value="04">4月</option>
															<option value="05" >5月</option>
															<option value="06" >6月</option>
															<option value="07" >7月</option>
															<option value="08">8月</option>
															<option value="09" >9月</option>
															<option value="10" >10月</option>
															<option value="11" >11月</option>
															<option value="12">12月</option>
											</select>
							   		 </div>
							   		 <div class="text">
										<div class="name" for="mechanismAgoName">往年服务机构</div>
											<input type="text" id="mechanismAgoName" placeholder="必填"  value="">	
									</div>
									<div class="text">
										<div class="name" for="turnoverProbability" >成交机率</div>
							    			<input type="text"  id="turnoverProbability" placeholder="必填"  onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"  
                                    onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'0')}else{this.value=this.value.replace(/\D/g,'')}"/>
							   		 </div>
		</div>
	</div>
	
		<div class="ui-body ui-body-b ui-corner-all none-border" data-theme="b">
	    <span class="con-title bg-orange">请输入跟进记录<span class="right-white color-orange" id="zhedie2" onclick="showtk('2')">一</span></span>
	    <div style="height:30px;"></div>
	    <div id="genjinjilu" style="display:block;">
	    	<div id="genjin_info1" style="display:block;">
				    <div class="text">
						<div class="name" for="startDate1">时间</div>
				    		<input type="text" class="dateorhbno" id="startDate1" name="startDate1" data-role="datebox" data-format="yyyy-MM-dd" readonly="readonly" style="color:#666666;padding: .7em;"/>
				    </div id="">
				     <div class="text">
													<div class="name" for="Process1">过程</div>
														<select tabindex="-1" name="Process1" id="Process1" data-native-menu="true" data-theme="a" >
															 <option value="0">	电话联系</option>   
															 <option value="1">	登门拜访</option>   
														</select>
					</div>
					<div class="text">
								<div class="name" for="Content1">跟进内容</div>
						    		<input type="text" name="Content1" id="Content1"   style="padding: .7em;"/>
					</div>
					<hr />
			</div>	
	    	<div id="genjin_info2" style="display:none;">
				    <div class="text">
						<div class="name" for="startDate2">时间</div>
				    		<input type="text" class="dateorhbno" id="startDate2" name="startDate2" data-role="datebox" data-format="yyyy-MM-dd" readonly="readonly" style="color:#666666;padding: .7em;"/>
				    </div id="">
				     <div class="text">
													<div class="name" for="Process2">过程</div>
														<select tabindex="-1" name="Process2" id="Process2" data-native-menu="true" data-theme="a" >
															 <option value="0">	电话联系</option>   
															 <option value="1">	登门拜访</option>   
														</select>
					</div>
					<div class="text">
								<div class="name" for="Content2">跟进内容</div>
						    		<input type="text" name="Content2" id="Content2"   style="padding: .7em;"/>
					</div>
					<hr />
			</div>	
	    	<div id="genjin_info3"  style="display:none;">
				    <div class="text">
						<div class="name" for="startDate3">时间</div>
				    		<input type="text" class="dateorhbno" id="startDate3" name="startDate3" data-role="datebox" data-format="yyyy-MM-dd" readonly="readonly" style="color:#666666;padding: .7em;"/>
				    </div id="">
				     <div class="text">
													<div class="name" for="Process3">过程</div>
														<select tabindex="-1" name="Process3" id="Process3" data-native-menu="true" data-theme="a" >
															 <option value="0">	电话联系</option>   
															 <option value="1">	登门拜访</option>   
														</select>
					</div>
					<div class="text">
								<div class="name" for="Content3">跟进内容</div>
						    		<input type="text" name="Content3" id="Content3"   style="padding: .7em;"/>
					</div>
					<hr />
			</div>	
	    	<div id="genjin_info4"  style="display:none;">
				    <div class="text">
						<div class="name" for="startDate4">时间</div>
				    		<input type="text" class="dateorhbno" id="startDate4" name="startDate4" data-role="datebox" data-format="yyyy-MM-dd" readonly="readonly" style="color:#666666;padding: .7em;"/>
				    </div id="">
				     <div class="text">
													<div class="name" for="Process4">过程</div>
														<select tabindex="-1" name="Process4" id="Process4" data-native-menu="true" data-theme="a" >
															 <option value="0">	电话联系</option>   
															 <option value="1">	登门拜访</option>   
														</select>
					</div>
					<div class="text">
								<div class="name" for="Content4">跟进内容</div>
						    		<input type="text" name="Content4" id="Content4"   style="padding: .7em;"/>
					</div>
					<hr />
			</div>	
	    	<div id="genjin_info5"  style="display:none;">
				    <div class="text">
						<div class="name" for="startDate5">时间</div>
				    		<input type="text" class="dateorhbno" id="startDate5" name="startDate5" data-role="datebox" data-format="yyyy-MM-dd" readonly="readonly" style="color:#666666;padding: .7em;"/>
				    </div id="">
				     <div class="text">
													<div class="name" for="Process5">过程</div>
														<select tabindex="-1" name="Process5" id="Process5" data-native-menu="true" data-theme="a" >
															 <option value="0">	电话联系</option>   
															 <option value="1">	登门拜访</option>   
														</select>
					</div>
					<div class="text">
								<div class="name" for="Content5">跟进内容</div>
						    		<input type="text" name="Content5" id="Content5"   style="padding: .7em;"/>
					</div>
					<hr />
			</div>	
		<div style="color:#FF0000;font-size:15px;margin-top:0px;text-align: center" onclick="addRecord()" > +</div>
		<div style="color:#FF0000;font-size:12px;margin-top:0px;text-align: left"> 注：以上信息一录入系统状态显示为（跟进中）</div>
		</div>	
			<div style="text-align:center;margin-top:20px;">
				<%--<div class="yellow_button2" style="width:40%;display: inline-block;"  id="closeWindow" onclick="forsubmit();" name="button">保 存</div>
				--%><input  type="submit" value="保 存">
			</div>
	</div>
</div>
</form>
</body>